
#ifndef _XMEMORY_H_
#define _XMEMORY_H_

#include "xtypes.h"
#include <new.h>

template <class _Ty>
inline _Ty * CALL_CON( _Ty * _MemPtr )
{
	_Ty * _Ptr = new(_MemPtr)_Ty;
	return _Ptr;
}

template <class _Ty>
inline void CALL_DEC( _Ty * _Ptr )
{
	_Ptr->~_Ty();
}


template <class _Ty>
_Ty * xNewObject()
{
	_Ty * _Ptr = (_Ty *)xMemoryAlloc(sizeof(_Ty));
	CALL_CON(_Ptr);
	return _Ptr;
}

template <class _Ty>
void xDeleteObject( _Ty *  _Ptr )
{
	CALL_DEC(_Ptr);
	xMemoryFree(_Ptr);
}


// C-Style Functions
wildptr_t xMemoryAlloc( int_t _Size );
void xMemoryFree( wildptr_t _Addr );

wildptr_t xMemoryCopy( wildptr_t _Dst, wildptr_t _Src, uint_t _Size );
wildptr_t xMemoryMove( wildptr_t _Dst, wildptr_t _Src, uint_t _Size );
wildptr_t xMemorySet( wildptr_t _Dst, int_t _Val, uint_t _Size );
wildptr_t xMemoryChar( wildptr_t _Dst, int_t _Val, uint_t _Size );


#endif _XMEMORY_H_



